#pragma once
#include "alife_abstract_registry.h"

enum ETaskState{
	eTaskStateFail			= 0,
	eTaskStateInProgress,
	eTaskStateCompleted,
	eTaskStateDummy			= u16(-1)
};
enum ETaskType{
	eTaskTypeStoryline		= 0,
	eTaskTypeAdditional,
	eTaskTypeInsignificant,
	eTaskTypeCount,
	eTaskTypeDummy	= u16(-1)
};


extern shared_str	g_active_task_id[eTaskTypeCount];
class CGameTask;

struct SGameTaskKey : public IPureSerializeObject<IReader,IWriter>,public IPureDestroyableObject 
{
	shared_str		task_id;
	CGameTask*		game_task;
	SGameTaskKey	(const shared_str& t_id):task_id(t_id),game_task(NULL)	{};
	SGameTaskKey	():task_id(NULL),game_task(NULL)						{};


	virtual void 	save								(IWriter &stream);
	virtual void 	load								(IReader &stream);
	virtual void 	destroy								();
};

using vGameTasks = xr_vector<SGameTaskKey>;
using vGameTasks_it = vGameTasks::iterator;

struct CGameTaskRegistry : public CALifeAbstractRegistry<u16, vGameTasks> 
{
	virtual void save(IWriter &stream)
	{
		CALifeAbstractRegistry<u16, vGameTasks>::save(stream);
		for(int i=0; i<eTaskTypeCount; ++i)
			save_data				(g_active_task_id[i],				stream);
	};
	virtual void load(IReader &stream)
	{
		CALifeAbstractRegistry<u16, vGameTasks>::load(stream);
		for(int i=0; i<eTaskTypeCount; ++i)
			load_data				(g_active_task_id[i],				stream);
	};
};
